<template>
  <div>
    <el-dialog
      title="下载"
      :close-on-click-modal="false"
      :visible.sync="form.dialogVisible"
      width="500px"
    >
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="播放地址">
          <el-input v-model="form.url" />
        </el-form-item>
        <el-form-item label="文件名称">
          <el-input v-model="form.fileName" />
        </el-form-item>
        <el-form-item>
          <el-button icon="el-icon-download" :disabled="!form.url" type="primary" @click="onSubmit">下载</el-button>
          <el-button @click="form.dialogVisible = false">取消</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'Form',
  data() {
    return {
      form: {
        dialogVisible: false,
        url: '',
        fileName: '',
        percentage: 0
      }
    }
  },
  created() {
    this.form.dialogVisible = true
  },
  methods: {
    initData(data) {
      this.form = Object.assign({}, data)
    },
    onSubmit() {
      // 下载进度
      this.form.percentage = 0
      this.$emit('addDownloadData', Object.assign({}, this.form))
      this.form.dialogVisible = false
    }
  }
}
</script>

<style scoped>

</style>
